package logic

import (
	"context"
	"go.uber.org/zap"
	"smart-health-platforms/pkg"
	"user_srv/internal/svc"
	"user_srv/model"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type CollectDeleteLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCollectDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CollectDeleteLogic {
	return &CollectDeleteLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 清空
func (l *CollectDeleteLogic) CollectDelete(in *user.CollectDeleteRequest) (*user.CollectDeleteResponse, error) {
	var coll model.Collection
	coll.UserId = int32(in.UserId)
	err := coll.ClearAll()
	if err != nil {
		pkg.Error("失败", zap.Error(err))
		return nil, err
	}
	return &user.CollectDeleteResponse{
		Msg: "成功",
	}, nil
}
